package com.example.pagingdemo.db;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.pagingdemo.model.GithubUser;

/**
 * @author: tuyrt7 on 2020/9/9.
 */
@Database(entities = {GithubUser.class}, version = 1,exportSchema = false)
public abstract class UserDatabase extends RoomDatabase {

    private static UserDatabase sUserDatabase;
    private static final String DB_NAME = "user_db";

    public static synchronized UserDatabase get(Context context) {
        if (sUserDatabase == null) {
            sUserDatabase = Room.databaseBuilder(context.getApplicationContext(), UserDatabase.class, DB_NAME)
                    .build();
        }
        return sUserDatabase;
    }

    public abstract GithubUserDao githubUserDao();
}
